package com.enjoy;


import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.*;

public class JdbcTest {

    Logger logger = LoggerFactory.getLogger("enjoy");

    @Test
    public void test1() throws SQLException, ClassNotFoundException {
        String url = "jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false";
        String user = "root";
        String password = "123456";
        Class.forName("com.mysql.jdbc.Driver");
        Connection connection = DriverManager.getConnection(url, user, password);
        connection.setAutoCommit(false);
        connection.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
        PreparedStatement preparedStatement = connection.prepareStatement("select * from employees where name ='zhuge88221'");
        ResultSet resultSet = preparedStatement.executeQuery();

        while (resultSet.next()) {
            String name = resultSet.getString("name");
            logger.info("name:{}", name);
        }
    }
}
